Skip to content

binder: Make a client SecurityPolicy test simpler and more realistic#12825

Open
jdcormie wants to merge 3 commits into
grpc:masterfrom
jdcormie:uid-proxy
Open

binder: Make a client SecurityPolicy test simpler and more realistic#12825
jdcormie wants to merge 3 commits into
grpc:masterfrom
jdcormie:uid-proxy

Conversation

@jdcormie
Copy link
Copy Markdown
Member

No description provided.

jdcormie added 3 commits May 22, 2026 17:53
Makes it easier to add new arguments with defaults in the future.

TAG=agy
CONV=e849839d-3cdc-4bcc-863d-9c8b6d2f47f6
LeakSafeOneWayBinder.Decorator lets us intercept Binder transactions on
the receiving side for testing. Unlike the existing OneWayBinderProxy
Decorator (works on the sending side), this lets a test inject code on
the same thread that calls onTransact(). We'll use this in a follow up
commit to simulate the UID of the caller.

TAG=agy
CONV=e849839d-3cdc-4bcc-863d-9c8b6d2f47f6
Add UID faking decorators using the new test support plumbing. This
allow tests to configure fake UIDs for the client and server just once
during the "arrange" phase. Use this new test infra to simplify a
RobolectricBinderTransportTest auth test.

TAG=agy
CONV=e849839d-3cdc-4bcc-863d-9c8b6d2f47f6
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Binder transport test infrastructure (especially under Robolectric) to make client SecurityPolicy authorization tests more realistic by simulating Binder calling-UID propagation in same-process Robolectric runs, and introduces a general “inbound binder decorator” hook to support that simulation.

Changes:

  • Add Robolectric-only helpers to pass/restore a fake calling UID via the transaction Parcel.
  • Add LeakSafeOneWayBinder.Decorator and plumb an inbound-transaction decorator through BinderTransport and the client transport factory.
  • Refactor BinderServerTransport construction to a Builder and simplify a Robolectric test accordingly.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
binder/src/test/java/io/grpc/binder/internal/RobolectricUidPropagation.java New Robolectric test helper to prepend UID on outgoing transactions and restore it on incoming handling.
binder/src/test/java/io/grpc/binder/internal/RobolectricBinderTransportTest.java Update test to use UID propagation decorators instead of global ShadowBinder manipulation.
binder/src/test/java/io/grpc/binder/internal/BinderServerTransportTest.java Switch test helper from a local builder wrapper to BinderServerTransport.Builder.
binder/src/main/java/io/grpc/binder/internal/LeakSafeOneWayBinder.java Add Decorator interface and identity decorator for transaction handler decoration.
binder/src/main/java/io/grpc/binder/internal/BinderTransport.java Accept/apply an inbound binder decorator when constructing the incoming LeakSafeOneWayBinder.
binder/src/main/java/io/grpc/binder/internal/BinderServerTransport.java Replace static factory with Builder, and plumb inbound binder decorator into transport construction.
binder/src/main/java/io/grpc/binder/internal/BinderServer.java Update server-side transport creation to use BinderServerTransport.Builder.
binder/src/main/java/io/grpc/binder/internal/BinderClientTransportFactory.java Add/configure inboundBinderDecorator on the client transport factory builder.
binder/src/main/java/io/grpc/binder/internal/BinderClientTransport.java Pass the factory’s inbound binder decorator through to the base BinderTransport.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants